<%-- 
    Document   : class-add-action
    Created on : Feb 14, 2012, 8:58:10 PM
    Author     : PhucAn
--%>

<%@page import="java.util.Date"%>
<%@page import="util.SharingUtil"%>
<%@page import="dao.ClassDAO"%>
<%
//process for click event of button Add  (class)
if(request.getParameter("add")!=null){
    ClassDAO daoCls=new ClassDAO();
    dto.Class cls=new  dto.Class();
    cls.setName(request.getParameter("class-name"));
    cls.setIsPublic(request.getParameter("is-public")!=null);
    cls.setTeacher(SharingUtil.getUser(session));
    cls.setCreatedDate(new Date());
    if(daoCls.create(cls)>0){
        SharingUtil.showMessage(session, "New class is created");
    }else{
        SharingUtil.showMessage(session, "Action failed. Class could not be created.");
    }
}
%>
